package cn.zhuangcloud.newversion.register;

import cn.zhuangcloud.newversion.common.controller.BaseController;
import cn.zhuangcloud.newversion.common.validator.TokenValidator;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;

@Clear(TokenValidator.class)
public class RegController extends BaseController {

    private static final RegService srv = RegService.me;

    @Before({RegInterceptor.class, GET.class})
    public void index() {
        renderTemplate("register.html");
    }

    @Before({POST.class,RegValidator.class})
    public void doRegister() {
        String username = getPara("username");
        String password = getPara("password");
        renderJson(srv.reg(username, password));
    }
}
